package com.ch.web.controller;

import com.ch.web.entity.user.XyTokenEntity;
import com.ch.web.service.XyTokenService;
import com.ch.web.utils.PageUtils;
import com.ch.web.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;




/**
 *
 *
 * @author chenHao
 * @email 1429542285@qq.com
 * @date 2022-04-27 22:59:18
 */
@RestController
@RequestMapping("xy/token")
public class XyTokenController {
    @Autowired
    private XyTokenService xyTokenService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = xyTokenService.queryPage(params);

        return  R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userId}")

    public  R info(@PathVariable("userId") Long userId){
		XyTokenEntity xyToken = xyTokenService.getById(userId);

        return  R.ok().put("xyToken", xyToken);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public  R save(@RequestBody XyTokenEntity xyToken){
		xyTokenService.save(xyToken);

        return  R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")

    public  R update(@RequestBody XyTokenEntity xyToken){
		xyTokenService.updateById(xyToken);

        return  R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public  R delete(@RequestBody Long[] userIds){
		xyTokenService.removeByIds(Arrays.asList(userIds));

        return  R.ok();
    }

}
